<?php
require_once("dbconnect.php");

$exeName=$_SESSION['user'];
$sql="select * from executives where exe_name='$exeName';";
$result=mysql_query($sql) or die(mysql_error());
while($row=mysql_fetch_assoc($result))
	{
	$id=$row['id'];
	}
//Assign each array to a variable
foreach($_POST['in'] as $row=>$time)
{
$date=dateconvert($_POST['date'],1);
//echo $date;
$timein=$time;
$timeout=$_POST['out'][$row];

$orgname= $_POST['org'][$row];
$industry=$_POST['industry'][$row];
$elp=$_POST['elp'][$row];
$contact=$_POST['contper'][$row];
$disgn=$_POST['disig'][$row];
$tel=$_POST['tel'][$row];
$vobject=$_POST['obj'][$row];
$visitout=$_POST['outcome'][$row];
$next= $_POST['nst'][$row];
$kms=$_POST['kms'][$row];
$remarks=$_POST['rem'][$row];




$query =  "insert into daily_activity(exe_id,timein,timeout, organisation, industry_type, elp, cont_person, disgnation, telephone,visit_objective, visit_outcome, nextstep,kms,remarks,edate)	values('$id','$timein','$timeout','$orgname','$industry','$elp','$contact','$disgn','$tel','$vobject','$visitout','$next','$kms','$remarks','$date')";
//echo $query;
if (!mysql_query($query))
{
die('Error: ' . mysql_error());
}
$msg="Successfully Inserted";
header("location:index.php?msg=".$msg);

}
function dateconvert($date,$func) 
{	
if ($func == 1)
{ //insert conversion
list($day, $month, $year) = split('[/.-]', $date);
$date = "$year-$month-$day";
return $date;
}
}
if($con==true) mysql_close($con);

?>